import Application from '../src/application';
import Context from '../src/context';
import { FilterChain } from '../src/utils/filter';
import bodyParser from '../src/filters/body-parser';

const app = new Application();

async function filter1(t: Context, chain: FilterChain<Context>): Promise<void> {
  await chain.next(t);
}

async function filter2(t: Context): Promise<void> {
  t.response.body = JSON.stringify(t.request.body);
  t.response.statusCode = 200;
}

app.use(bodyParser());
app.use(filter1);
app.use(filter2);

app.listen(3000);
